Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 通过TX服务器检查URL安全性 #125

Merged
merged 6 commits into from
Nov 15, 2024

Conversation

icarus-ai
Copy link
Contributor

似乎比较鸡肋

@Redmomn
Copy link
Collaborator

Redmomn commented Nov 15, 2024

对于引用的代码,应该标明来源
例如

LagrangeGo/client/operation.go

Lines 1279 to 1337 in 593cc96

// GetUnidirectionalFriendList 获取单向好友列表
// ref https://github.com/Mrs4s/MiraiGo/blob/54bdd873e3fed9fe1c944918924674dacec5ac76/client/web.go#L23
func (c *QQClient) GetUnidirectionalFriendList() (ret []*entity.Friend, err error) {
webRsp := &struct {
BlockList []struct {
Uin uint32 `json:"uint64_uin"`
NickBytes string `json:"bytes_nick"`
Age uint32 `json:"uint32_age"`
Sex uint32 `json:"uint32_sex"`
SourceBytes string `json:"bytes_source"`
} `json:"rpt_block_list"`
ErrorCode int32 `json:"ErrorCode"`
}{}
rsp, err := c.webSsoRequest("ti.qq.com", "OidbSvc.0xe17_0", fmt.Sprintf(`{"uint64_uin":%v,"uint64_top":0,"uint32_req_num":99,"bytes_cookies":""}`, c.Uin))
if err != nil {
return nil, err
}
if err = json.Unmarshal(utils.S2B(rsp), webRsp); err != nil {
return nil, errors.Wrap(err, "unmarshal json error")
}
if webRsp.ErrorCode != 0 {
return nil, fmt.Errorf("web sso request error: %v", webRsp.ErrorCode)
}
for _, block := range webRsp.BlockList {
decodeBase64String := func(str string) string {
b, err := base64.StdEncoding.DecodeString(str)
if err != nil {
return ""
}
return utils.B2S(b)
}
ret = append(ret, &entity.Friend{
Uin: block.Uin,
Nickname: decodeBase64String(block.NickBytes),
Age: block.Age,
Source: decodeBase64String(block.SourceBytes),
})
}
return
}
// DeleteUnidirectionalFriend 删除单向好友
// ref https://github.com/Mrs4s/MiraiGo/blob/54bdd873e3fed9fe1c944918924674dacec5ac76/client/web.go#L62
func (c *QQClient) DeleteUnidirectionalFriend(uin int64) error {
webRsp := &struct {
ErrorCode int32 `json:"ErrorCode"`
}{}
rsp, err := c.webSsoRequest("ti.qq.com", "OidbSvc.0x5d4_0", fmt.Sprintf(`{"uin_list":[%v]}`, uin))
if err != nil {
return err
}
if err = json.Unmarshal(utils.S2B(rsp), webRsp); err != nil {
return errors.Wrap(err, "unmarshal json error")
}
if webRsp.ErrorCode != 0 {
return errors.Errorf("web sso request error: %v", webRsp.ErrorCode)
}
return nil
}

// ref https://github.com/Mrs4s/MiraiGo/blob/54bdd873e3fed9fe1c944918924674dacec5ac76/client/pb/web/WebSsoBody.proto#L1
message STServiceMonitItem {
optional string cmd = 1;
optional string url = 2;
optional int32 errcode = 3;
optional uint32 cost = 4;
optional uint32 src = 5;
}
message STServiceMonitReq {
repeated STServiceMonitItem list = 1;

@Redmomn
Copy link
Collaborator

Redmomn commented Nov 15, 2024

protobuf最好统一改为proto3格式

@Redmomn Redmomn merged commit 2d6282c into LagrangeDev:master Nov 15, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants